[Top] [Prev] [Next] [Bottom] [Contents]

SaGetBlobToFile

Retrieves Blob data from a database table and writes it to a file. (Sybase Only)

Synopsis

#include "WorkingDialog.h"
int SaGetBlobToFile(int vendor,
							char *sv, 
							char *db,
							char *tab,
							char *col,
							int coltype,
							char *where,
							int chunksize,
							char *path);

Arguments

vendor
SGESYBASE is the only valid value.
sv
pointer to a string containing the destination server name
db
pointer to a string containing the destination database name
tab
pointer to a string containing the destination table name
col
pointer to a string containing the destination column name
coltype
SA_TEXT for text blobs or SA_BINARY for binary (image) blobs
where
pointer to a string containing a where clause that is guaranteed to return a unique row in a table when used with a select statement.
chunksize
number of bytes to read in one trip to the database. -1 signifies to use the default size. Increasing this number could improve performance. Memory limits must be taken into consideration.
path
pointer to a string containing a UNIX path and filename to write the blob into.

Return Values

Returns 0 on success or a value less than zero on error. The following is a list of possible errors:

-1 NULL parameter was passed as an argument to the function.

-2 internal error occurred.

-3 failure to open the path argument for write.

-4 a failure occurred attempting to write to the file.

-5 failure reading the Blob from the database.

Description

SaGetBlobToFile is a convenient routine which extracts a blob value from a column in a database table, and writes it to a file.

Example

#include "WorkingDialog.h"
...	
int code;
SaGetBlobDone(SGESYBASE);
if((code = SaGetBlobToFile( 
				SGESYBASE,
				"CEZANNE",
				"pubs2",
				"au_pix",
				"pic",
				SA_BINARY,
				"where au_id = `192-748-2293'",
				-1,
				"/tmp/image")) < 0) {
printf("Failed writing blob to file with code %d.\n", 							code);	
}
else
	printf("Blob successfully written to file!\n");

See Also



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.